<div class="controls">
	<div id="uploader_{$id}"><div id="picker">选择文件</div></div><!-- 上传按钮 -->
	<input type="hidden" name="{$name}" value="{$value}" id="file_upload_{$id}"><!-- 隐藏域 -->
	<div id="file_list_{$id}"><!-- 文件列表 -->
		{notempty name="file"}
			<div>
				{$file.name}
				<a onclick="remove_file_{$id}(this, {$file.id})"><i class="fa fa-trash"></i></a>
			</div>
		{/notempty}
	</div>
</div>
<script type="text/javascript">
	var uploader_{$id} = WebUploader.create({
		swf: '__STATIC__/webuploader/js/Uploader.swf',
		server: "{:url('core/File/uploadFile')}",
		pick: "#uploader_{$id}",
	});

	uploader_{$id}.on('fileQueued', function(file) {
		uploader_{$id}.upload();

		toast.showLoading();
	});
	uploader_{$id}.on('uploadSuccess', function(file, ret) {
		if ( ret.status==1 ) {
			toast.success("上传成功！");

			$('#file_list_{$id}').html('<div>'+ret.data.file.name+' <a onclick="remove_file_{$id}'+'(this,'+ret.data.file.id+')"><i class="icon-trash"></i></a></div>');
			$('#file_upload_{$id}').val(ret.data.file.id);
		} else { // 上传失败
			toast.error(""+ret.info);
		}
	});
	uploader_{$id}.on('uploadError', function(file) {
		toast.error("上传失败！")
	});
	uploader_{$id}.on('uploadComplete', function(file) {
		toast.hideLoading();
	});
	$("#uploader_{$id}").find(".webuploader-pick").last().css({
        width: "64px",
        height: "26px"
    });

	function remove_file_{$id}(obj, attachId) {
		$('#file_upload_{$id}').val('');
		$(obj).parent('div').remove();
	}
</script>